package com.rui.patterns.factory.simpleFactory;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : SimpleCofferfACTORY
 * @createTime : [2022/2/19 21:59]
 * @description : [简单咖啡工厂,用来生产咖啡]
 */

public class SimpleCoffeeFactory {

    public Coffee createCoffee(String type) {
        //声明Coffee类型的变量，根据不同的类型创建不同的Coffee子类对象
        Coffee coffee = null;
        if("american".equals(type)){
            coffee = new AmericanCoffee();
        }else if("latte".equals(type)){
            coffee = new LatteCoffee();
        }else {
            throw new RuntimeException("对不起，您所点的咖啡没有");
        }
        return coffee;
    }
}
